Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). The axis labels are collectively referred to as the index.
documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html
In [2]:
import pandas as pd
import numpy as np
In [3]:
my_simple_series = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
my_simple_series
Out[3]:
In [4]:
my_simple_series.index
Out[4]:
In [5]:
my_simple_series = pd.Series(np.random.randn(5))
my_simple_series
Out[5]:
Access a series like a NumPy array
In [6]:
my_simple_series[:3]
Out[6]:
In [7]:
my_dictionary = {'a' : 45., 'b' : -19.5, 'c' : 4444}
my_second_series = pd.Series(my_dictionary)
my_second_series
Out[7]:
Access a series like a dictionary
In [8]:
my_second_series['b']
Out[8]:
note order in display; same as order in "index"
note NaN
In [9]:
pd.Series(my_dictionary, index=['b', 'c', 'd', 'a'])
Out[9]:
In [10]:
my_second_series.get('a')
Out[10]:
In [11]:
unknown = my_second_series.get('f')
type(unknown)
Out[11]:
In [12]:
pd.Series(5., index=['a', 'b', 'c', 'd', 'e'])
Out[12]:
In [ ]: